/*
	Copyright (c) 2009-2011, Stefan Webb.

	This file is part of SimpleML. Please read the file "license.txt", 
	which contains the conditions under which this software is distributed.
*/

/*!
	\file shared.cpp
	\author Stefan Webb
	\brief Main function.
*/

#include "stdafx.h"

int main(int argc, wchar_t* argv[])
{
	utf16 s1[] = {1 << 8, 0};
	utf16 s2[] = {5 << 8, 0};
	utf16 s3[] = {4 << 8, 0};

	PatriciaTree ptree;
	//ptree.insert(s3);
	//ptree.insert(s2);
	//ptree.insert(s1);
	//ptree.remove(s3);
	//ptree.remove(s1);

	utf16* javaKeywords[] = {L"abstract", L"continue", L"for", L"new", L"switch", L"assert", L"default", L"goto", L"package", L"synchronized", L"boolean", L"do", 
		L"if", L"private", L"this", L"break", L"double", L"implements", L"protected", L"throw", L"byte", L"else", L"import", L"public", L"throws", L"case", L"enum",
		L"instanceof", L"return", L"transient", L"catch", L"extends", L"int", L"short", L"try", L"char", L"final", L"interface", L"static", L"void", L"class", 
		L"finally", L"long", L"strictfp", L"volatile", L"const", L"float", L"native", L"super", L"while"};

	//utf16* javaKeywords[] = {L"private", L"do", L"volatile", L"axiom"};

	for (unsigned int i = 0; i < 20; i++)
		ptree.insert(javaKeywords[i]);
	ptree.remove(javaKeywords[3]);
	//ptree.insert(s3);

	//ptree.print();

	/*if (ptree.contains(javaKeywords[23]))
		wcout << L"Contains string '" << javaKeywords[23] << L"'" << endl;

	if (ptree.contains(s3))
		wcout << L"Contains string 3" << endl;
	if (ptree.contains(s1))
		wcout << L"Contains string 1" << endl;
	if (ptree.contains(s2))
		wcout << L"Contains string 2" << endl;*/

	//wcout << ptree.first() << endl;
	if (ptree.contains(L"goto"))
		console << L"Contains goto" << endl;
	console << L"Cursor is at: " << ptree.cursor() << endl;

	/*for (unsigned int i = 0; i < 20; i++) {
		utf16* string = ptree.successor();
		if (string)
			wcout << string << endl;
		else
			wcout << L"EMPTY" << endl;
	}*/

	//wcout << ptree.last() << endl;
	/*wcout << ptree.cursor() << endl;
	for (unsigned int i = 0; i < 10; i++) {
		utf16* string = ptree.predecessor();
		if (string)
			wcout << string << endl;
		else
			wcout << L"EMPTY" << endl;
	}*/

	// Wait until a key is pressed until exiting. So program output doesn't disappear!!
	console.pressAnyKey();
}